package com.job.project.service;

import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * @Author 王博
 * @DateTime 2024-07-04 14:15
 */
@Component
public class AsyncService {

    @Async("otherExecutor")
    public void asyncForOne() {
        System.out.println("one:"+Thread.currentThread().getName());
        System.out.println("one:"+Thread.currentThread().getThreadGroup().getName());
    }

    @Async
    public void asyncForTwo() {
        System.out.println("two:"+Thread.currentThread().getName());
        System.out.println("two:"+Thread.currentThread().getThreadGroup().getName());
    }

    public void sync() {
        System.out.println("sync:"+Thread.currentThread().getName());
        System.out.println("sync:"+Thread.currentThread().getThreadGroup().getName());
    }
}
